﻿bool IsPrime(int number)
{
    for (int i = 2; i <= Math.Sqrt(number); i++)
    {
        if (number % i == 0)
        {
            return false;
        }
    }

    return true;
}


Console.Write("请输入一个正整数：");
int number;
var input = Console.ReadLine();
while (!int.TryParse(input, out number) || number < 0)
{
    Console.Write("请输入正整数：");
    input = Console.ReadLine();
    
}

Console.Write($"数字 {number} 的所有素数因子为：");

for (int i = 2; i <= number; i++)
{
    if (number % i == 0 && IsPrime(i))
    {
        Console.Write(i + " ");
    }
}